package com.knowledge.plus.创建线程and线程池.注解创建线程.service.impl;

import com.knowledge.plus.创建线程and线程池.注解创建线程.service.TestAsyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author TPF
 * @since 2022/9/29
 */
@Slf4j
@Service
public class TestAsyncServiceImpl implements TestAsyncService {

    /**
     * 异步执行方法
     */
    // @Async
    @Async("scheduledExecutorService")  // 指定线程池
    public void asyncService() throws InterruptedException {
        System.out.println("execute2: 当前线程 id = " + Thread.currentThread().getId() + "；name = " + Thread.currentThread().getName());
    }

}
